from pprint import pprint
filedir = 'E:/0051.txt'
outinfodict={}
with open(filedir) as file:
    newlist=file.read().splitlines()
    print(newlist)

    for one in  newlist:
        # print(one)
        one=one.replace('(','').replace('),','').replace("'",'').replace(');','')
        # print(one)
        parts=one.split(',')
        # print(parts)
        time=parts[0].strip()
        lessionid=parts[1].strip()
        userid=parts[2].strip()
        toDict = {'lessonid': lessionid, 'checkintime': time}
        if  userid not in outinfodict:
            outinfodict[userid]=[]
        outinfodict[userid].append(toDict)

    pprint(outinfodict)
#

ndict={}
list=["'zxcv',210,100","'qwer',10,9","'zzzz',45,20"]
for one in list:
    one=one.replace("'",'').strip()
    parts=one.split(',')
    name=parts[0].strip()
    age=int(parts[1].strip())
    lession=int(parts[2].strip())
    # print(name,age)
    todict={'lessonid':lession,'name':name}
    # print(todict)
    if age not in  ndict:
        ndict[age]=[]
        ndict[age].append(todict)
pprint(ndict)



